import datetime
import pytz
from pytz import timezone


# rounds a datetime up to the nearest 15 minutes increment
def roundDt(dt):
  dt = dt.replace(second = 0, microsecond = 0)
  m = dt.minute
  for x in (45, 30, 15, 0):
    if m > x:
      dt = dt + datetime.timedelta(minutes = (x + 15 - m))
      break    
  return dt
  
def toTZ(time, tz):
  if time.tzinfo == None:
    time = time.replace(tzinfo = pytz.UTC)
  return time.astimezone(timezone(tz))  